{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "d00e2c6a",
   "metadata": {},
   "outputs": [],
   "source": [
    "tang_str ='hello python'"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "id": "c64250e1",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "hello python\n"
     ]
    }
   ],
   "source": [
    "print(tang_str)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "id": "07fe30d4",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'hellopython'"
      ]
     },
     "execution_count": 6,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "tang=\"hello\"+\"python\"\n",
    "tang"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "id": "ca033c2a",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'hello pythonhello pythonhello python'"
      ]
     },
     "execution_count": 7,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "tang_str * 3"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "id": "2b05da22",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "9"
      ]
     },
     "execution_count": 11,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "len(tang)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "c4a5d015",
   "metadata": {},
   "source": [
    "字符操作"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "id": "22357b46",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "['1', '2', '3', '4', '5']"
      ]
     },
     "execution_count": 13,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "tang=\"1 2 3 4 5\"\n",
    "tang.split()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "id": "c962d51c",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "['1', '2', '3', '4', '5']"
      ]
     },
     "execution_count": 14,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "tang=\"1,2,3,4,5\"\n",
    "tang.split(\",\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "id": "d58e1b57",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'1,2,3,4,5'"
      ]
     },
     "execution_count": 15,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "tang"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "id": "b8d4cea8",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'1,2,3,4,5'"
      ]
     },
     "execution_count": 16,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "tang_str=\"\"\n",
    "tang_str.join(tang)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "id": "839f3e94",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'hello world'"
      ]
     },
     "execution_count": 17,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "tang=\"hello python\"\n",
    "tang.replace(\"python\",\"world\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 18,
   "id": "179ecaf2",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'hello world'"
      ]
     },
     "execution_count": 18,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "tang=\"hello python\"\n",
    "tang2=tang.replace(\"python\",\"world\")\n",
    "tang2"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 19,
   "id": "62facd35",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'HELLO WORLD'"
      ]
     },
     "execution_count": 19,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "tang2.upper()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 21,
   "id": "1943bf77",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'hello world'"
      ]
     },
     "execution_count": 21,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "tang2='HELLO WORLD'\n",
    "tang2.lower()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 22,
   "id": "f1e23d4d",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'hello python'"
      ]
     },
     "execution_count": 22,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "tang=\"  hello python\"\n",
    "tang.strip()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 23,
   "id": "1293307d",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'  hello python'"
      ]
     },
     "execution_count": 23,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "tang"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 24,
   "id": "b146928b",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'hello python'"
      ]
     },
     "execution_count": 24,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "tang.lstrip()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 25,
   "id": "4624f208",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'tang yu id'"
      ]
     },
     "execution_count": 25,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "\"{} {} {}\".format(\"tang\",\"yu\",\"id\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 26,
   "id": "989de2a2",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'id yu tang'"
      ]
     },
     "execution_count": 26,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "\"{2} {1} {0}\".format(\"tang\",\"yu\",\"id\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 31,
   "id": "b9d1917c",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'10 5 1'"
      ]
     },
     "execution_count": 31,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "'{tang} {yu} {di}'.format(tang=10,yu=5,di=1)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 32,
   "id": "ec27a8db",
   "metadata": {},
   "outputs": [],
   "source": [
    "tang='tang yu di:'\n",
    "a=123\n",
    "b=456\n",
    "c=789\n",
    "result=\"%s %f %d\" %(tang,b,c)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 33,
   "id": "8f02679b",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'tang yu di: 456.000000 789'"
      ]
     },
     "execution_count": 33,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "result"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "2c28c581",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.11.4"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
